package com.ruoyi.tzai.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.ruoyi.tzai.mapper.NewsContentMapper;
import com.ruoyi.tzai.domain.NewsContent;
import com.ruoyi.tzai.service.INewsContentService;
import com.ruoyi.common.utils.DateUtils;

/**
 * 资讯内容Service业务层处理
 * 
 * @author tzai
 * @date 2025-10-27
 */
@Service
public class NewsContentServiceImpl implements INewsContentService 
{
    @Autowired
    private NewsContentMapper newsContentMapper;

    /**
     * 查询资讯内容
     * 
     * @param contentId 资讯内容主键
     * @return 资讯内容
     */
    @Override
    public NewsContent selectNewsContentByContentId(Long contentId)
    {
        return newsContentMapper.selectNewsContentByContentId(contentId);
    }

    /**
     * 根据文章ID和语言查询资讯内容
     * 
     * @param articleId 文章ID
     * @param language 语言
     * @return 资讯内容
     */
    @Override
    public NewsContent selectNewsContentByArticleIdAndLanguage(Long articleId, String language)
    {
        return newsContentMapper.selectNewsContentByArticleIdAndLanguage(articleId, language);
    }

    /**
     * 查询资讯内容列表
     * 
     * @param newsContent 资讯内容
     * @return 资讯内容
     */
    @Override
    public List<NewsContent> selectNewsContentList(NewsContent newsContent)
    {
        return newsContentMapper.selectNewsContentList(newsContent);
    }

    /**
     * 新增资讯内容
     * 
     * @param newsContent 资讯内容
     * @return 结果
     */
    @Override
    @Transactional
    public int insertNewsContent(NewsContent newsContent)
    {
        newsContent.setCreateTime(DateUtils.getNowDate());
        return newsContentMapper.insertNewsContent(newsContent);
    }

    /**
     * 修改资讯内容
     * 
     * @param newsContent 资讯内容
     * @return 结果
     */
    @Override
    @Transactional
    public int updateNewsContent(NewsContent newsContent)
    {
        return newsContentMapper.updateNewsContent(newsContent);
    }

    /**
     * 批量删除资讯内容
     * 
     * @param contentIds 需要删除的资讯内容主键
     * @return 结果
     */
    @Override
    @Transactional
    public int deleteNewsContentByContentIds(Long[] contentIds)
    {
        return newsContentMapper.deleteNewsContentByContentIds(contentIds);
    }

    /**
     * 删除资讯内容信息
     * 
     * @param contentId 资讯内容主键
     * @return 结果
     */
    @Override
    @Transactional
    public int deleteNewsContentByContentId(Long contentId)
    {
        return newsContentMapper.deleteNewsContentByContentId(contentId);
    }

    /**
     * 根据文章ID删除资讯内容
     * 
     * @param articleId 文章ID
     * @return 结果
     */
    @Override
    @Transactional
    public int deleteNewsContentByArticleId(Long articleId)
    {
        return newsContentMapper.deleteNewsContentByArticleId(articleId);
    }
}

